﻿using System.Collections.Generic;
using System.Linq;

namespace Plot.Primitives
{
    internal class AxisDivider : PShape
    {
        public double Distance { get; set; }
        public int Count { get; set; }
        public double Height { get; set; }
        public double HeightShift { get; set; }

        public AxisDivider(double x, double y, double angle, double distance, int count, double height, double heightShift) 
            : base(x, y, angle)
        {
            Distance = distance;
            Count = count;
            Height = height;
            HeightShift = heightShift;
        }

        public override IEnumerator<PShape> GetEnumerator()
        {
            return Enumerable.Range(1, Count - 1).
                Select(i => new PLine(i*Distance + StartPoint.X, -Height/2 + HeightShift + StartPoint.Y, i*Distance + StartPoint.X, Height/2 + HeightShift + StartPoint.Y) {PivotPoint = PivotPoint, Angle = Angle}).
                GetEnumerator();
        }
    }
}